package algorithm;

/**
 * @description: 数组反转
 * @author: apple
 * @date:  2021/11/16 11:38 下午
 * @version 1.0
 **/
public class reverse2 {

    public static void main(String[] args) {

        String[] ts = {"A" , "B" , "C" , "D"};

        System.out.println("交换前");

        for (int i = 0; i < ts.length; i++) {
            System.out.print(ts[i] + " ");
        }

        for (int i = 0; i < ts.length / 2; i++) {
            String temp = ts[i];
            ts[i] = ts[ts.length - 1 - i];
            ts[ts.length - 1 - i] = temp;
        }


        System.out.println("\n交换后");

        for (int i = 0; i < ts.length; i++) {
            System.out.print(ts[i] + " ");
        }
    }
}
